{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
                <h1 class="page-header" id="wse_id" style="display: none;">{{ head.wse }}</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="container">
                                    <form role="form" class="form-horizontal">
                                        <div class="form-group">
                                            <label class="col-sm-12">工单创建人</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" readonly="readonly" id="creator"
                                                       value={{ data.creator }}></input>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12">申请人</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" readonly="readonly" id="applicant"
                                                       value={{ data.applicant }}></input>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12">标题</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" readonly="readonly" id="title"
                                                       value={{ data.title }}></input>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12">MAC地址</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" readonly="readonly" id="mac"
                                                       value={{ data.mac }}>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12">申请理由</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" rows="5" id='reason'
                                                          readonly="readonly">{{ data.reason }}</textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">wifi名称</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="name"
                                                       value={{ data.name }} readonly="readonly">
                                            </div>
                                        </div>


                                        <br>
                                        <div class="form-group">
                                            <label class="col-sm-12">审核流程步骤</label>
                                            <div class="col-sm-6">
                                                <div class="ystep1"></div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-1">审批意见</label>
                                            <div class="col-sm-6">
                                                {% if data.has_approved %}
                                                    <p>{{ data.state_value }}</p>
                                                {% else %}
                                                    {% for t in transitions %}
                                                        <label class="radio-inline {% if t.condition == '同意' %}text-success{% else %}text-danger{% endif %}">
                                                            <input type="radio" name='transitions'
                                                                   id={{ t.id }} condition={{ t.condition }} {% if t.condition == '同意' %}checked{% endif %}>{{ t.condition }}
                                                        </label>
                                                    {% endfor %}
                                                {% endif %}
                                            </div>
                                        </div>

                                        {% if data.transition_status == '运维' %}
                                            {% if data.name != 'Cy-work' %}
                                                <div class="form-group">
                                                    <label class="col-sm-1">是否已处理</label>
                                                    <div class="col-sm-6">
                                                        {% if data.has_approved %}
                                                            {% if data.has_handle %}
                                                                <p>已处理</p>
                                                            {% else %}
                                                                <p>未处理</p>
                                                            {% endif %}
                                                        {% else %}
                                                            <label class="radio-inline text-success">
                                                                <input type="radio" name='has_handle' id="has_handle"
                                                                       value="1" checked>是
                                                            </label>
                                                            <label class="radio-inline text-danger">
                                                                <input type="radio" name='has_handle' id="has_handle"
                                                                       value="0">否
                                                            </label>
                                                        {% endif %}
                                                    </div>
                                                </div>
                                            {% endif %}
                                            {% if data.name == 'Cy-work' %}
                                                <div class="form-group">
                                                    <label class="col-sm-1">是否自动开通</label>
                                                    <div class="col-sm-6">
                                                        {% if data.has_approved %}
                                                            {% if data.has_add_mac %}
                                                                <p>已开通</p>
                                                            {% else %}
                                                                <p>未开通</p>
                                                            {% endif %}
                                                        {% else %}
                                                            <label class="radio-inline">
                                                                <input type="radio" name='has_add_mac' id="has_add_mac"
                                                                       value="1">是
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="radio" name='has_add_mac' id="has_add_mac"
                                                                       value="0">否
                                                            </label>
                                                        {% endif %}
                                                    </div>
                                                </div>
                                            {% endif %}
                                        {% endif %}

                                        {% if not data.has_approved %}
                                            <div class="form-group">
                                                <label class="col-sm-12">审批意见(可选)</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" rows="3" id='opinion'
                                                              placeholder="你拒绝本次申请的理由是?"></textarea>
                                                </div>
                                            </div>
                                        {% endif %}
                                        <input id="transition_status" value="{{ data.transition_status }}"
                                               style="display: none">

                                        {% if data.has_approved %}
                                        {% else %}
                                            <!--<div class="form-group">
                                              <label class="checkbox-inline col-sm-12">
                                                <div class="col-sm-6">
                                                  <input type="checkbox" id='sendmail'>邮件通知
                                                </div>
                                              </label>
                                            </div>-->
                                            <div class="form-group">
                                                <div class="col-sm-6">
                                                    <button type="button" class="btn btn-primary" id='bt-commit'>提交
                                                    </button>
                                                </div>
                                            </div>
                                            {% if data.transition_status == '运维' %}
                                                <div class="form-group">
                                                    <label class="col-sm-12" for="TextArea">转单给网管处理</label>
                                                    <div class="col-sm-6">
                                                        <select id="to_anthoer_admin" style="width: 100%">
                                                            <option value="0" selected="selected">选择其他网管</option>
                                                        </select>
                                                    </div>
                                                    <button type="button" class="btn btn-success" id='bt-transfer'>转交
                                                    </button>
                                                </div>
                                            {% endif %}
                                        {% endif %}
                                    </form>
                                    <hr>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="myModalLabel">执行中...请勿关闭或者刷新页面</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal" role="form">
                                {% if data.can_execute %}
                                    {% if not data.has_approved %}
                                        <div class="form-group" id='load' style="display: none;">
                                            <label class="col-sm-12"></label>
                                            <div class="col-sm-12">
                                                <div class="ball"></div>
                                            </div>
                                        </div>
                                    {% endif %}
                                {% endif %}
                                <div class="form-group" id='show-msg'>
                                    <label class="col-sm-3 control-label"></label>
                                    <div class="col-sm-8">
                                        <p id='load-msg'></p>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer" id="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>
        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/failure_decalre_workflow_approve.js?v=809eb891a7d3305e2b6f7c51b7d357ca650bda"></script>
    <script src="/static/js/ystep.js"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/ystep.css" rel="stylesheet" type="text/css">
    <!--<link href="/static/css/load.css" rel="stylesheet" type="text/css">-->
{% endblock %}
